include $(GOROOT)/src/Make.inc
TARG=server
ifeq ($(GOOS),windows)
TARG:=$(TARG).exe
endif
GOFILES=\
	main.go\
	log.go\
	config.go\
	handler.go\

PKGS+=system
LDIMPORTS=-L pkg
GCIMPORTS=-I pkg

all: $(TARG)
clean: $(addsuffix .clean, $(PKGS))
	rm -rf *.o *.a *.[$(OS)] [$(OS)].out $(CLEANFILES) $(TARG)
%.make:
	$(MAKE) -C $* 

PREREQ+=$(patsubst %,%.make,$(DEPS))

%.lib:$(addsuffix .make, $($*_LIB))

$(TARG):$(PKGS) _go_.$O
	$(LD) $(LDIMPORTS) -o $@ _go_.$O
$(PKGS):$(addsuffix .make, $(PKGS))
	cp $@/_obj/$@.a pkg
_go_.$O: $(GOFILES) $(PREREQ)
	$(GC) $(GCIMPORTS) -o $@ $(GOFILES)

%.clean:
	$(MAKE) -C $* clean

